# data_setup.py
import os
from DataloaderModule import DataloaderModule
from EmbeddingStorageModule import EmbeddingStorageModule

def setup_data(directory_path, md_path,docx_path,faiss_index_path="faiss_index"):
    print("初始化数据加载模块...")
    # data_loader = DataloaderModule(directory_path="./data")
    data_loader = DataloaderModule(directory_path)
    data_loader.load_all_documents(md_path,docx_path)
    #加载处理结果
    # data_loader.display_save_summary()
    print(f"数据加载完成，文档总数: {len(data_loader.documents)}")

    print("初始化嵌入与存储模块...")
    embedding_storage = EmbeddingStorageModule(data_loader=data_loader)
    embedding_storage.create_faiss_vector_store()
    print("向量索引创建成功，存储路径:", faiss_index_path)

    return data_loader, embedding_storage

if __name__ == "__main__":
    directory_path = r"E:\政策\langchain_huitong\data"
    md_path = r"E:\政策\langchain_huitong\data\md"
    docx_path = r"E:\政策\langchain_huitong\data\docx"
    setup_data(directory_path, md_path,docx_path)
